import axios from './axios'
import qs from 'qs'
import {
    baseUrl
} from '@/config/config'

/**
 * 伯乐奖列表
 * @param {*} params 
 * @returns 
 */
export const getBoleList = (params) => {
    return new Promise((resolve, reject) => {
        axios({
            url: baseUrl + '/api/bole/award?' + qs.stringify(params),
            method: 'GET'
        }).then(res => {
            resolve(res.data)
        }).catch(error => {
            reject(error)
        })
    })
}

/**
 * 伯乐奖领取确认
 * @returns 
 */
 export const updateBole = (id) => {
    return new Promise((resolve, reject) => {
      axios({
        url: baseUrl + '/api/bole/award/' + id,
        method: 'PUT'
      }).then(res => {
        var data = res.data
        resolve(data)
      }).catch(error => {
        reject(error)
      })
    })
}

/**
 * 伯乐奖结算确认
 * @returns 
 */
 export const closeBole = (id) => {
  return new Promise((resolve, reject) => {
    axios({
      url: baseUrl + '/api/colse/bole/award',
      method: 'PUT'
    }).then(res => {
      var data = res.data
      resolve(data)
    }).catch(error => {
      reject(error)
    })
  })
}

/**
 * 导出
 */
 export const downloadData = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: baseUrl + '/api/bole/down/load/data',
      method: 'get',
      params: params,
      responseType: 'blob'
    }).then(res => {
      var data = res.data
      resolve(data)
    }).catch(error => {
      reject(error)
    })
  })
}
